package com.tc.excel;

import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.ReflectionUtils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

/**
 * @Auther: tianchao
 * @Date: 2025/2/14 15:48
 * @Description:
 */
public class ExcelFieldFilter implements ReflectionUtils.FieldFilter {

    private final Class<? extends Annotation> annotationType;

    public ExcelFieldFilter(Class<? extends Annotation> annotationType) {
        this.annotationType = annotationType;
    }

    /**
     * Determine whether the given field matches.
     *
     * @param field the field to check
     */
    @Override
    public boolean matches(Field field) {
        return AnnotationUtils.getAnnotation(field, annotationType)!=null;
    }
}
